package utopia_activities;

import com.example.utopia.shoppinglist.R;
import com.example.utopia.shoppinglist.R.layout;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class create_account extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.create_account);
		ActionBar bar = getActionBar();
		bar.setDisplayHomeAsUpEnabled(true);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) 
	{    
	   switch (item.getItemId()) 
	   {        
	      case android.R.id.home:            
	         Intent intent = new Intent(this, logon_screen.class);            
	         startActivity(intent);            
	         return true;        
	      default:            
	         return super.onOptionsItemSelected(item);    
	   }
	}
	
	public void OnButtonClick(View view){
    	if (view.getId()==R.id.create) {
    		final Context context = this;
            
    		EditText username= (EditText) findViewById(R.id.EditText01);
    		EditText email= (EditText) findViewById(R.id.email);
    		EditText password= (EditText) findViewById(R.id.password);
    		EditText passwordconfirm= (EditText) findViewById(R.id.password_confirm);
    		
    		String user = username.getText().toString();
    		String mail = email.getText().toString();
    		String pass = password.getText().toString();
    		String passconfirm = passwordconfirm.getText().toString();
    		
    		if(user.equals("")|mail.equals("")|password.equals("")|passconfirm.equals("")){
    			Toast.makeText(this, "Please enter all information!", Toast.LENGTH_LONG).show();
    		}
    		else{
   	         
    		Toast.makeText(this, "User " + user + " created!", Toast.LENGTH_LONG).show();	
    		Intent intent = new Intent(this, logon_screen.class);            
   	         startActivity(intent);
    		}
    		
    		/*RegistryMatcher matcher = new RegistryMatcher();
	        
	        matcher.bind(UUID.class, new UUIDTransform());
	        matcher.bind(Date.class, new DateTransform(java.text.DateFormat.getDateInstance(java.text.DateFormat.DEFAULT, Locale.US)));
	        
	        Persister persister = new Persister(matcher);
	        OnlineEinkaufsblock block = new OnlineEinkaufsblock(new LoggerImpl(), persister, context, new DefaultHttpClient());
	        block.setUrl("http://www.matthiaswelz.de:8094/OutOfAPPles");
	        
	        block.tryLogin(user, pass);
	        
	        if (block.isLoggedIn()){
	        Toast.makeText(context, "sucessfully logged in", Toast.LENGTH_SHORT).show(); 
	        startActivity(new Intent(context, menu.class));
	        }*/

    	}
	}
}
